﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Kindohm.KSynth.Library;

namespace Kindohm.KSynth.UI
{
    public partial class EnvelopeControls : UserControl
    {
        public EnvelopeControls()
        {
            InitializeComponent();
        }

        public Synthesizer Synthesizer
        {
            get;
            set;
        }

        public uint Attack
        {
            get { return (uint)this.attackSlider.Value; }
            set { this.attackSlider.Value = value; }
        }

        public uint Decay
        {
            get { return (uint)this.decaySlider.Value; }
            set { this.decaySlider.Value = value; }
        }

        public uint Sustain
        {
            get { return (uint)this.sustainSlider.Value; }
            set { this.sustainSlider.Value = value; }
        }

        public double Pitch
        {
            get { return this.pitchSlider.Value; }
            set { this.pitchSlider.Value = value; }
        }

        private void attackSlider_ValueChanged(object sender, EventArgs e)
        {
            if (this.Synthesizer != null)
                this.Synthesizer.Envelope.Attack = (uint)this.attackSlider.Value;
        }

        private void sustainSlider_ValueChanged(object sender, EventArgs e)
        {
            if (this.Synthesizer != null)
                this.Synthesizer.Envelope.Sustain = (uint)this.sustainSlider.Value;

        }

        private void decaySlider_ValueChanged(object sender, EventArgs e)
        {
            if (this.Synthesizer != null)
                this.Synthesizer.Envelope.Decay = (uint)this.decaySlider.Value;

        }

        private void pitchSlider_ValueChanged(object sender, EventArgs e)
        {
            if (this.Synthesizer != null)
                this.Synthesizer.PitchBend = this.pitchSlider.Value;

        }


    }
}
